package AlgoVorlesung;

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
import java.util.Random;

public class RndColor extends Frame {
	public static void main(String[] args) {
		RndColor r = new RndColor();
		r.rnd();
	}

	final int W = 300;
	final int H = 200;
	Image m_Img;
	int[] m_Pix = new int[W * H];
	MemoryImageSource m_ImgSrc;

	public RndColor() {
		setSize(300, 200);
		m_ImgSrc = new MemoryImageSource(W, H, m_Pix, 0, W);
		m_Img = createImage(m_ImgSrc);
		setVisible(true);
	}

	public void update(Graphics g) {
		
	}

	public void paint(Graphics g) {

	}

	public void rnd() {
		Random rnd = new Random();
		while (true) {
			for (int i = 0; i < W * H; ++i) {
				m_Pix[i] = rnd.nextInt();
			}
			m_Img.flush();
			getGraphics().drawImage(m_Img,0,0,this);
			try{
				Thread.sleep(100);
			}catch(InterruptedException e){
				
			}
		}
	}
}
